package com.kfm.jdbc.day04;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.util.Properties;

public class Demo03 {

    public static void main(String[] args) throws Exception {
//        Map<String, String> map = new HashMap<>();
//        map.put("driverClassName", "com.mysql.cj.jdbc.Driver");
//        map.put("url", "jdbc:mysql://localhost:3306/company");
//        map.put("username", "root");
//        map.put("password", "");

        Properties prop = new Properties();

        prop.load(Demo03.class.getClassLoader().getResourceAsStream("db.properties"));
//        prop.put("driverClassName", "com.mysql.cj.jdbc.Driver");
//        prop.put("url", "jdbc:mysql://localhost:3306/company");
//        prop.put("username", "root");
//        prop.put("password", "");

        DataSource dataSource = DruidDataSourceFactory.createDataSource(prop);

        System.out.println(dataSource.getConnection());
    }
}
